package com.lxw.manage_cms.controller;

import com.lxw.api.cms.CmsSiteControllerApi;
import com.lxw.framework.domain.cms.CmsSite;
import com.lxw.framework.model.response.CommonCode;
import com.lxw.framework.model.response.QueryResponseResult;
import com.lxw.framework.model.response.QueryResult;
import com.lxw.manage_cms.service.ICmsSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;



@RestController
@RequestMapping("site")
public class CmsSiteController implements CmsSiteControllerApi {


    @Autowired
    ICmsSiteService cmsSiteService;

    @GetMapping("/list")
    @Override
    public QueryResponseResult findSites() {

        List<CmsSite> sites = cmsSiteService.findSites();
        QueryResult<CmsSite> queryResult = new QueryResult<>();
        queryResult.setList(sites);
        queryResult.setTotal(sites.size());

        QueryResponseResult queryResponseResult = new QueryResponseResult(CommonCode.SUCCESS, queryResult);
        return queryResponseResult;
    }
}
